home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Workbench Add-On
/
Workbench Add-On - Volume 1.iso
/
Dev
/
Oberon
/
source
/
amiga
/
Commodities.mod
< prev
next >
Wrap
Text File
|
1995-06-29
|
12KB
|
431 lines
(***************************************************************************
$RCSfile: Commodities.mod $
Description: Interface to commodities.library
Created by: fjc (Frank Copeland)
$Revision: 3.8 $
$Author: fjc $
$Date: 1995/06/04 23:13:14 $
Includes Release 40.15
(C) Copyright 1985-1993 Commodore-Amiga, Inc.
All Rights Reserved
Oberon-A interface Copyright © 1994-1995, Frank Copeland.
This file is part of the Oberon-A Interface.
See Oberon-A.doc for conditions of use and distribution.
***************************************************************************)
<* STANDARD- *>
MODULE [2] Commodities;
IMPORT
SYS := SYSTEM, Kernel, e := Exec, Ie := InputEvent, Km := KeyMap,
s := Sets;
(**-- Pointer declarations ---------------------------------------------*)
TYPE
NewBrokerPtr * = POINTER TO NewBroker;
InputXpressionPtr * = POINTER TO InputXpression;
IXPtr * = POINTER TO IX;
CxObjPtr * = POINTER TO CxObj;
CxMsgPtr * = POINTER TO CxMsg;
(*
** $VER: commodities.h 38.4 (24.2.93)
**
** Commodities definitions.
*)
(*****************************************************************************)
CONST
(* Sizes for various buffers *)
nameLen * = 24;
titleLen * = 40;
descrLen * = 40;
TYPE
NameStr * = ARRAY nameLen OF CHAR;
TitleStr * = ARRAY titleLen OF CHAR;
DescrStr * = ARRAY descrLen OF CHAR;
NewBroker * = RECORD
version * : SHORTINT; (* Must be set to NB_VERSION *)
name * : POINTER TO NameStr;
title * : POINTER TO TitleStr;
descr * : POINTER TO DescrStr;
unique * : s.SET16;
flags * : s.SET16;
pri * : SHORTINT;
port * : e.MsgPortPtr;
reservedChannel * : INTEGER;
END;
CONST
(* constant for NewBroker.version *)
nbVersion * = 5; (* Version of NewBroker structure *)
(* Flags for NewBroker.unique *)
duplicate * = 0;
unique * = 1; (* will not allow duplicates *)
notify * = 2; (* sends cxmUnique to existing broker *)
(* Flags for NewBroker.flags *)
showHide * = 4;
(*****************************************************************************)
TYPE
(* Fake data types for system private objects *)
CxObj = RECORD END;
CxMsg = RECORD END;
(* Pointer to a function returning a LONG *)
PFL = PROCEDURE () : LONGINT;
(*****************************************************************************)
CONST
(* Commodities object types *)
invalid * = 0; (* not a valid object (probably null) *)
filter * = 1; (* input event messages only *)
typeFilter * = 2; (* obsolete, do not use *)
send * = 3; (* sends a message *)
signal * = 4; (* sends a signal *)
translate * = 5; (* translates input event into chain *)
broker * = 6; (* application representative *)
debug * = 7; (* dumps info to serial port *)
custom * = 8; (* application provides function *)
zero * = 9; (* system terminator node *)
(*****************************************************************************)
CONST
(* Commodities message types *)
cxmIEvent * = 32;
cxmCommand * = 64;
(* Only mIEvent messages are passed through the input network. Other types
* of messages are sent to an optional port in your broker. This means that
* you must test the message type in your message handling, if input messages
* and command messages come to the same port.
*
* cxmIEvent: Messages of this type rattle around the Commodities input
* network. They are sent to you by a Sender object, and passed
* to you as a synchronous function call by a Custom object.
*
* The message port or function entry point is stored in the
* object, and the ID field of the message will be set to what
* you arrange issuing object.
*
* The data section of the message will point to the input event
* triggering the message.
*
* cxmCommand: These messages are sent to a port attached to your Broker.
* They are sent to you when the controller program wants your
* program to do something. The ID value identifies the command.
*)
CONST
(* ID values associated with a message of type mCommand *)
cmdDisable * = 15; (* please disable yourself *)
cmdEnable * = 17; (* please enable yourself *)
cmdAppear * = 19; (* open your window, if you can *)
cmdDisappear * = 21; (* go dormant *)
cmdKill * = 23; (* go away for good *)
cmdListChg * = 27; (* Someone changed the broker list *)
cmdUnique * = 25; (* someone tried to create a broker
* with your name. Suggest you appear.
*)
(*****************************************************************************)
TYPE
InputXpression * = RECORD
version * : SHORTINT; (* must be set to ixVersion *)
class * : SHORTINT; (* class must match exactly *)
code * : s.SET16; (* Bits that we want *)
codeMask * : INTEGER; (* Set bits here to indicate which bits in code
* are don't care bits.
*)
qualifier * : s.SET16; (* Bits that we want *)
qualMask * : s.SET16; (* Set bits here to indicate which bits in
* qualifier are don't care bits
*)
qualSame * : s.SET16; (* synonyms in qualifier *)
END;
IX * = InputXpression;
CONST
(* constant for InputXpression.version *)
ixVersion * = 2;
(* constants for InputXpression.qualSame *)
ixSymShift * = 0; (* left- and right- shift are equivalent *)
ixSymCaps * = 1; (* either shift or caps lock are equivalent *)
ixSymAlt * = 2; (* left- and right- alt are equivalent *)
ixSymShiftMask * = {Ie.lShift, Ie.rShift};
ixSymCapsMask * = ixSymShiftMask + {Ie.capsLock};
ixSymAltMask * = {Ie.lAlt, Ie.rAlt};
(* constant for InputXpression.qualMask *)
ixNormalQuals * = -{Ie.relativeMouse}; (* avoid RELATIVEMOUSE *)
(*****************************************************************************)
CONST
(* Error returns from CxBroker() *)
errOk * = 0; (* No error *)
errSysErr * = 1; (* System error, no memory, etc *)
errDup * = 2; (* uniqueness violation *)
errVersion * = 3; (* didn't understand NewBroker.nb_Version *)
(*****************************************************************************)
CONST
(* Return values from CxObjError() *)
coErrIsNull * = 0; (* you called CxObjError(NULL) *)
coErrNullAttach * = 1; (* someone attached NULL to my list *)
coErrBadFilter * = 2; (* a bad filter description was given *)
coErrBadType * = 3; (* unmatched type-specific operation *)
(*****************************************************************************)
TYPE
LONGBOOL * = e.LONGBOOL;
CONST
LTRUE * = e.LTRUE;
LFALSE * = e.LFALSE;
(**-- Library Base variable --------------------------------------------*)
CONST
commoditiesName * = "commodities.library";
VAR
base * : e.LibraryPtr;
(**-- Library Functions ------------------------------------------------*)
(*
** $VER: commodities_protos.h 38.4 (27.2.92)
*)
TYPE
CustomProcType * = PROCEDURE ( obj : CxObjPtr; msg : CxMsgPtr );
(* --- functions in V36 or higher (distributed as Release 2.0) ---*)
(* OBJECT UTILITIES *)
PROCEDURE CreateCxObj* [base,-30]
( type [0] : e.ULONG;
arg1 [8] : SYS.LONGWORD;
arg2 [9] : SYS.LONGWORD )
: CxObjPtr;
PROCEDURE CxBroker* [base,-36]
( VAR nb [8] : NewBroker;
VAR error [0] : LONGINT )
: CxObjPtr;
PROCEDURE ActivateCxObj* [base,-42]
( co [8] : CxObjPtr;
true [0] : LONGBOOL )
: LONGBOOL;
PROCEDURE DeleteCxObj* [base,-48]
( co [8] : CxObjPtr );
PROCEDURE DeleteCxObjAll* [base,-54]
( co [8] : CxObjPtr );
PROCEDURE CxObjType* [base,-60]
( co [8] : CxObjPtr )
: e.ULONG;
PROCEDURE CxObjError* [base,-66]
( co [8] : CxObjPtr )
: s.SET32;
PROCEDURE ClearCxObjError* [base,-72]
( co [8] : CxObjPtr );
PROCEDURE SetCxObjPri* [base,-78]
( co [8] : CxObjPtr;
pri [0] : LONGINT )
: LONGINT;
(* OBJECT ATTACHMENT *)
PROCEDURE AttachCxObj* [base,-84]
( headObj [8] : CxObjPtr;
co [9] : CxObjPtr );
PROCEDURE EnqueueCxObj* [base,-90]
( headObj [8] : CxObjPtr;
co [9] : CxObjPtr );
PROCEDURE InsertCxObj* [base,-96]
( headObj [8] : CxObjPtr;
co [9] : CxObjPtr;
pred [10] : CxObjPtr );
PROCEDURE RemoveCxObj* [base,-102]
( co [8] : CxObjPtr );
(* TYPE SPECIFIC *)
PROCEDURE SetTranslate* [base,-114]
( translator [8] : CxObjPtr;
VAR events [9] : Ie.InputEvent );
PROCEDURE SetFilter* [base,-120]
( filter [8] : CxObjPtr;
text [9] : ARRAY OF CHAR );
PROCEDURE SetFilterIX* [base,-126]
( filter [8] : CxObjPtr;
VAR ix [9] : IX );
PROCEDURE ParseIX* [base,-132]
( description [8] : ARRAY OF CHAR;
VAR ix [9] : IX )
: LONGINT;
(* COMMON MESSAGE *)
PROCEDURE CxMsgType* [base,-138]
( cxm [8] : CxMsgPtr )
: s.SET32;
PROCEDURE CxMsgData* [base,-144]
( cxm [8] : CxMsgPtr )
: e.APTR;
PROCEDURE CxMsgID* [base,-150]
( cxm [8] : CxMsgPtr )
: LONGINT;
(* MESSAGE ROUTING *)
PROCEDURE DivertCxMsg* [base,-156]
( cxm [8] : CxMsgPtr;
headobj [9] : CxObjPtr;
ret [10] : CxObjPtr );
PROCEDURE RouteCxMsg* [base,-162]
( cxm [8] : CxMsgPtr;
co [9] : CxObjPtr );
PROCEDURE DisposeCxMsg* [base,-168]
( cxm [8] : CxMsgPtr );
(* INPUT EVENT HANDLING *)
PROCEDURE InvertKeyMap* [base,-174]
( ansicode [0] : e.ULONG;
event [8] : Ie.InputEventDummyPtr;
km [9] : Km.KeyMapPtr )
: BOOLEAN;
PROCEDURE AddIEvents* [base,-180]
( events [8] : Ie.InputEventDummyPtr );
(*--- functions in V38 or higher (Release 2.1) ---*)
(* MORE INPUT EVENT HANDLING *)
PROCEDURE MatchIX* [base,-204]
( event [8] : Ie.InputEventDummyPtr;
ix [9] : IXPtr )
: BOOLEAN;
(**-- C Macros defined as procedures -----------------------------------*)
<*$LongVars+*>
(*************************
* object creation macros
*************************)
(**-----------------------------------*)
PROCEDURE [0] CxFilter * (d : e.APTR)
: CxObjPtr;
BEGIN (* CxFilter *)
RETURN CreateCxObj (filter, d, NIL)
END CxFilter;
(**-----------------------------------*)
PROCEDURE [0] CxTypeFilter * (type : e.APTR)
: CxObjPtr;
BEGIN (* CxTypeFilter *)
RETURN CreateCxObj (typeFilter, type, NIL)
END CxTypeFilter;
(**-----------------------------------*)
PROCEDURE [0] CxSender * (port : e.MsgPortPtr; id : e.APTR)
: CxObjPtr;
BEGIN (* CxSender *)
RETURN CreateCxObj (send, port, id)
END CxSender;
(**-----------------------------------*)
PROCEDURE [0] CxSignal * (task : e.TaskPtr; sig : INTEGER)
: CxObjPtr;
BEGIN (* CxSignal *)
RETURN CreateCxObj (signal, task, sig)
END CxSignal;
(**-----------------------------------*)
PROCEDURE [0] CxTranslate * (ie : Ie.InputEventDummyPtr)
: CxObjPtr;
BEGIN (* CxTranslate *)
RETURN CreateCxObj (translate, ie, NIL)
END CxTranslate;
(**-----------------------------------*)
PROCEDURE [0] CxDebug * (id : e.APTR)
: CxObjPtr;
BEGIN (* CxDebug *)
RETURN CreateCxObj (debug, id, NIL)
END CxDebug;
(**-----------------------------------*)
PROCEDURE [0] CxCustom * (action : CustomProcType; id : e.APTR)
: CxObjPtr;
BEGIN (* CxCustom *)
RETURN CreateCxObj (custom, action, id)
END CxCustom;
(**-- Library Base variable --------------------------------------------*)
<*$LongVars-*>
(**-----------------------------------*)
PROCEDURE* [0] CloseLib (VAR rc : LONGINT);
BEGIN (* CloseLib *)
IF base # NIL THEN e.CloseLibrary (base) END;
END CloseLib;
BEGIN
base := e.OpenLibrary (commoditiesName, e.libraryMinimum);
IF base # NIL THEN Kernel.SetCleanup (CloseLib) END
END Commodities.